fix: treat '<error>' testcases as failed instead of passed - #774
Conversation
`parse_testcase_result` only inspected the `<failure>` and `<skipped>`
child elements of a `<testcase>`:
if skipped is None and failed is None:
return "passed", ""
JUnit XML also uses `<error>` for testcases that did not complete, e.g.
an uncaught exception in Python's `unittest` or a crashing binary. Such
a testcase has neither `<failure>` nor `<skipped>`, so it fell into the
branch above and was reported as `passed`.
That is the worst possible failure mode for a verification report: a
broken test silently shows up as a green `(passed)` badge next to the
requirement it is supposed to verify.
Handle `<error>` explicitly and map it to `failed`, using the element's
`message` attribute as the result text. An existing `<failure>` still
takes precedence, so the reported message stays the assertion message
when both elements are present.
License Check Results🚀 The license check job ran with the Bazel command: bazel run --lockfile_mode=error //src:license-checkStatus: Click to expand output |
|
Documentation preview for this pull request is available at: |
|
Do you have an |
AlexanderLanin
left a comment
There was a problem hiding this comment.
LGTM, lets wait for copilot
There was a problem hiding this comment.
Pull request overview
Fixes incorrect reporting of JUnit <testcase> results by treating <error> elements as failures (instead of incorrectly marking them as passed), improving accuracy of requirement verification reporting.
Changes:
- Update
parse_testcase_resultto detect<error>and map it to("failed", <message>). - Add unit tests covering
<error>handling and precedence of<failure>over<error>.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/extensions/score_source_code_linker/xml_parser.py |
Extends testcase result parsing to treat <error> as failed while preserving <failure> precedence. |
src/extensions/score_source_code_linker/tests/test_xml_parser.py |
Adds regression tests for <error> cases and <failure>-over-<error> precedence. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
parse_testcase_resultonly inspected the<failure>and<skipped>child elements of a<testcase>:JUnit XML also uses
<error>for testcases that did not complete, e.g. an uncaught exception in Python'sunittestor a crashing binary. Such a testcase has neither<failure>nor<skipped>, so it fell into the branch above and was reported aspassed.That is the worst possible failure mode for a verification report: a broken test silently shows up as a green
(passed)badge next to the requirement it is supposed to verify.Handle
<error>explicitly and map it tofailed, using the element'smessageattribute as the result text. An existing<failure>still takes precedence, so the reported message stays the assertion message when both elements are present.📌 Description
🚨 Impact Analysis
✅ Checklist